package com.fitso.wicket.panel.user;

import java.io.Serializable;

import org.apache.log4j.Logger;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.SubmitLink;

import com.fitso.wicket.FitsoSession;

class UserSignOutForm extends Form<Object> implements Serializable {
	// Only change on breaking changes, i.e., removing fields
	private static final long serialVersionUID = 1L;

	private static final Logger logger = Logger.getLogger(UserSignOutForm.class);

	public UserSignOutForm(final String id) {
		super(id);
		add(new SubmitLink("signOutLink") {
			public void onSubmit() {
				logger.info("signing out: " + FitsoSession.get().getUser());

				// sign out the user
				FitsoSession.get().signOut();
				setResponsePage(getApplication().getHomePage());
			}
		});
	}
}